package com.it.selfAfter.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.it.selfAfter.entity.Users;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.*;

import java.util.Date;

@Mapper
public interface UserMapper extends BaseMapper<Users> {

    @Select("select * from sys_users where mobile=#{phone}")
    Users getUsersByPhone(@Param("phone") String phone);

    @Select("select * from sys_users where user_id=#{userId}")
    Users getUsersByUserId(@Param("userId") String userId);

    @Update("update sys_users set today_saying = #{quote} where mobile=#{phone}")
    int updateQuote(@Param("phone") String phone, @Param("quote") String quote);

    @Update("update sys_users set images = #{avatarUrl} where mobile=#{phone}")
    int updateImgByPhone(@Param("phone") String phone, @Param("avatarUrl") String avatarUrl);

    @Update("update sys_users set uuid = #{uuid} where mobile=#{phone}")
    int updateUUIDByPhone(@Param("phone") String phone, @Param("uuid") String uuid);
    
    
    @Insert("INSERT INTO sys_users (username, password, email, mobile, name, salt, pwd_update_time, last_login_time, create_time, delete_time," +
          " is_deleted, is_admin, is_super_admin, today_saying, images, uuid, user_id) " +
          "VALUES (#{username}, #{password}, #{email}, #{mobile}, #{name}, #{salt}, #{pwdUpdateTime}, #{lastLoginTime}, #{createTime}, " +
          "#{deleteTime}, #{isDelete}, #{isAdmin}, #{isSuperAdmin}, #{phone}, #{initImg}, #{uuid}, #{userId})")
    int add (@Param("username") String username, @Param("password") String password, @Param("email") String email, @Param("mobile") String mobile,
             @Param("name")String name, @Param("salt")String salt, @Param("pwdUpdateTime") Date pwdUpdateTime, @Param("lastLoginTime") Date lastLoginTime,
             @Param("createTime") Date createTime, @Param("deleteTime") Date deleteTime, @Param("isDelete") Integer isDelete, @Param("isAdmin") Integer isAdmin,
             @Param("isSuperAdmin") Integer isSuperAdmin, @Param("phone") String quote, @Param("initImg") String initImg, @Param("uuid") String uuid, @Param("userId") String userId);
}
